<?php

namespace App\Http\Controllers\Frontend;

use Laravel\Lumen\Routing\Controller as BaseController;

use App\Model\CarModelObject;
use App\Model\CarVin;
use Illuminate\Http\Request;

class VinController extends BaseController
{

    /**
     * show all brands
     */
    public function index( Request $request, $factory, $series, $displacement ){


    }

    /**
     * 获取单个model object信息
     */
    public function info( Request $request, $vin ){

        $res = [
            'desc' => '查询成功！',
            'size' => 1,
            'statusCode' => 1,
            'result' => []
        ];

        $single = CarVin::getInfo( $vin );
        if( !empty( $single ) ){
            $res = [
                'desc' => '查询成功',
                'size' => count( $single ),
                'statusCode' => 200,
//                'result' => json_encode( $single, true )
                'result' => $single
            ];
        }else{
            $res = [
                'desc' => '抱歉，查询无结果！',
                'size' => 0,
                'statusCode' => -2,
                'result' => []
            ];
        }

        echo json_encode( $res );


    }

}
